package org.openea.eap.module.obpm.util.form;

import java.util.*;





public class Util
{
  public static <T> Map<String, T> map(String key, T value) {
    Map<String, T> map = new HashMap<>();
    map.put(key, value);
    return map;
  }


  public static <T> List<T> list(T... value) {
    if (value == null) {
      return null;
    }
    List<T> list = new ArrayList<>();
    for (T t : value) {
      list.add(t);
    }
    return list;
  }



  public static <T> T[] array(T... value) { return value; }



  public static int[] intArray(int... value) { return value; }



  public static <T> Set<T> set(T... value) {
    if (value == null) {
      return null;
    }
    Set<T> set = new HashSet<>();
    for (T t : value) {
      set.add(t);
    }
    return set;
  }


  public static <T> boolean contains(Object data, T... compareDatas) {
    Set<T> set = set(compareDatas);
    if (set == null) {
      return false;
    }
    return set.contains(data);
  }

  public static boolean isEqual(Object data1, Object data2) {
    if (data1 == null && data2 == null) {
      return true;
    }
    if (data1 == null) {
      return false;
    }
    if (data2 == null) {
      return false;
    }
    return data1.toString().equals(data2.toString());
  }


  public static boolean equals(Object data1, Object data2) { return isEqual(data1, data2); }
}
